﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;

namespace JiuMeiMall.PMethod
{
    /// <summary>
    /// 判断图片尺寸
    /// </summary>
    public class IsDetermineImageSize
    {
        /// <summary>
        /// 判断图片的是否满足尺寸大小
        /// </summary>
        /// <param name="fileUpLoad">图片文件流</param>
        /// <param name="height">限制的高</param>
        /// <param name="width">图片的宽</param>
        /// <param name="dic">图片的宽和高dic["height"]&dic["width"]</param>
        /// <returns>返回true尺寸正确</returns>
        public static bool ValidateFileDimensions(HttpPostedFile fileUpLoad, int height, int width, ref Dictionary<string, int> dic)
        {
            using (System.Drawing.Image myImage = System.Drawing.Image.FromStream(fileUpLoad.InputStream))
            {
                dic["height"] = myImage.Height;
                dic["width"] = myImage.Width;
                return (myImage.Height == height && myImage.Width == width);
            }
        }
        /// <summary>
        /// 判断图片的是否满足尺寸大小
        /// </summary>
        /// <param name="fileUpLoad">图片文件流</param>
        /// <param name="height">限制的高</param>
        /// <param name="width">图片的宽</param>
        /// <param name="dic">图片的宽和高dic["height"]&dic["width"]</param>
        /// <returns>返回true尺寸正确</returns>
        public static bool ValidateFileDimensions(HttpPostedFile fileUpLoad, int height, int width)
        {
            using (System.Drawing.Image myImage = System.Drawing.Image.FromStream(fileUpLoad.InputStream))
            {               
                return (myImage.Height == height && myImage.Width == width);
            }
        }
    }
}
